{layout name="passport:layout" /}
<div class="titlebar">
    <svg class="icon fn-f18" aria-hidden="true"><use xlink:href="#icon-setup_icon"></use></svg> 应用配置
    <div class="fn-right"></div>
</div>
<div class="tipbox tipbox-warning mb10">
    友情提示：<br />
    <span class="gray">
        <p>1、如开启服务商支付,请确认绑定的授权公众号或小程序在微信官方商户号中授权服务商APPID权限。</p>
        <p class="blue">2、应用客户端认证ID：{$member_miniapp.service_id}</p>
    </span>
</div>
<div class="tabs">
    <ul class="tab_menu">
        <a href="{:url('passport.setting/index')}"><li>关于应用</li></a>
        <a href="{:url('passport.setting/edit')}"><li class="current">应用配置</li></a>
        {if $member_miniapp.miniapp.is_wechat_pay}<a href="{:url('passport.setting/wepay')}"><li>微信支付</li></a>{/if}
        {if $member_miniapp.miniapp.is_alipay_pay}<a href="{:url('passport.setting/alipay')}"><li>支付宝</li></a>{/if}
        <a href="{:url('passport.setting/tplmsg')}"><li>模板消息</li></a>
    </ul>
</div>
<form id="form" action="{:url('system/passport.setting/edit')}">
<input type="hidden" name="id" value="{$member_miniapp.id}" />
<table class="formtable">
    <tr>
        <td class="w150">应用名称:</td>
        <td><input datatype="*" class="input w200" type="text" name="appname" value="{$member_miniapp.appname}" /></td>
    </tr>
    <tr>
        <td>微信服务商:</td>
        <td>
            <span class="badge bg-gray"><input class="radio" type="radio" name="is_psp" value="0" {if $member_miniapp.is_psp == 0}checked="true"{/if}>独立商户号</span>
            <span class="badge bg-blue"><input class="radio" type="radio" name="is_psp" value="1" {if $member_miniapp.is_psp == 1}checked="true"{/if}>微信服务商</span>
        </td>
    </tr>
    <tr class="psp_appid {$member_miniapp.is_psp?'fn-show':'fn-hide'}">
        <td>服务商APPID:</td>
        <td><input class="input w200" type="text" name="psp_appid" value="{$member_miniapp.psp_appid}" /> <span class="gray">请填写微信服务商的公众号APPID</span></td>
    </tr>
</table>
{if $member_miniapp.miniapp.types != 'mp' && $member_miniapp.miniapp.types != 'app'}
    <div class="titlebar"><svg class="icon fn-f18" aria-hidden="true"><use xlink:href="#icon-xiaochengxu"></use></svg> 小程序</div>
    <table class="formtable">
        {if $member_miniapp.miniapp.is_openapp}
        <tr><td class="w150">AppID(小程序):</td><td><input datatype="*" class="input w200" type="text" name="miniapp_appid" value="{$member_miniapp.miniapp_appid}" /></td></tr>
        <tr><td>AppSecret(小程序):</td><td><input id="miniapp_secret" datatype="*" class="input w400" type="text" name="miniapp_secret" value="{$member_miniapp.miniapp_secret}" /><button type="button" class="miniapp_secret button ">随机生成</button> </td></tr>
        {else}
        <tr><td class="w150">AppID(小程序):</td><td>{$member_miniapp.miniapp_appid}</td></tr>
      {/if}
        <tr><td>小程序状态颜色:</td><td><input readonly="readonly" datatype="*" class="readonly w200 input ui-color" type="text" name="navbar_color" value="{$member_miniapp.navbar_color}" /></td></tr>
        <tr>
            <td>小程序文字样式:</td>
            <td>
                <select datatype="*" name="navbar_style" class="select w200">
                    <option value="#ffffff"{if $member_miniapp.navbar_style=='#ffffff'} selected{/if}>白色</option>
                    <option value="#000000"{if $member_miniapp.navbar_style=='#000000'} selected{/if}>黑色</option>
                </select>
            </td>
        </tr>
    </table>
{/if}
{if $member_miniapp.miniapp.types != 'program' && $member_miniapp.miniapp.types != 'app'}
<div class="titlebar"><svg class="icon fn-f18" aria-hidden="true"><use xlink:href="#icon-gonggaoxinxi"></use></svg> 公众号</div>
<table class="formtable">
    {if $member_miniapp.miniapp.is_openapp}
    <tr><td class="w150">授权验证(URL):</td><td>{:url('system/event.wechatMp/getWechat',['app' => $member_miniapp.id],true,true)}</td></tr>
    <tr><td>AppID(公众号):</td><td><input class="input w200" datatype="*" type="text" name="mp_appid" value="{$member_miniapp.mp_appid}" /></td></tr>
    <tr><td>AppSecret(公众号):</td><td><input id="mp_secret" class="input w400" datatype="*" type="text" name="mp_secret" value="{$member_miniapp.mp_secret}" />
        <button type="button" class="mp_create button ">随机生成</button> </td></tr>
    <tr><td>Token(公众号):</td>
        <td>
            <input id="mp_token" class="input w400" datatype="*" type="text" name="mp_token" value="{if $member_miniapp.mp_token}{$member_miniapp.mp_token}{else}TOKEN{/if}" />
            <button type="button" class="mp_token button">随机生成</button> <br />
            <span class="gray">Token必须为英文或数字，长度为3-32字符。如不填写则默认为“TOKEN”。</span>
        </td>
    </tr>
    <tr>
        <td>EncodingAESKey:</td>
        <td><input id="mp_aes_key" class="input w400" datatype="*" type="text" name="mp_aes_key" value="{$member_miniapp.mp_aes_key}" />
            <button type="button" class="mp_aes_key button">随机生成</button><br />
            <span class="gray">公众号消息加密密钥由43位字符组成，可随机修改，字符范围为A-Z，a-z，0-9。</span>
        </td>
    </tr> 
    {else}
    <tr><td class="w150">AppID(公众号):</td><td><span class="ext-select w200">{$member_miniapp.mp_appid}</span></td></tr>
    {/if}
</table>
{/if}
<table class="formtable">   
    <tr>
        <td class="w150"></td>
        <td>
            <input type="submit" value="确定" class="button button-blue submit" />
            <input type="reset" value="重置" class="button button-blank" />
        </td>
    </tr>
</table>
</form>
<script type="text/javascript">
Do('base','layer','form','color',function () {
    $('#form').isForm();
    $('input[name=is_psp]').change(function(){
        0 == $(this).val() ? $('.psp_appid').hide() : $('.psp_appid').show();
    })   
    $('.miniapp_secret').click(function(){
        $('#miniapp_secret').val(randomWord(32,32,32))
    })
    $('.mp_create').click(function(){
        $('#mp_secret').val(randomWord(32,32,32))
    })
    $('.mp_create').click(function(){
        $('#mp_secret').val(randomWord(32,32,32))
    })
    $('.mp_token').click(function(){
        $('#mp_token').val(randomWord(30,30,30))
    }) 
    $('.mp_aes_key').click(function(){
        $('#mp_aes_key').val(randomWord(43,43,43))
    })     
});
</script>